
if test -z "$2"
then
	echo "$0 <iso file> <vdi file>"
	exit
fi

ISOFILE="$1"
VDIFILE="$2"
TMPFILE="temporarydiskimage.img"
echo "Creating VDI file "
rm -f $ISOFILE.img

dd if=/dev/zero bs=1M count=50 of=$TMPFILE
sudo /sbin/mkfs.vfat $TMPFILE
syslinux $TMPFILE

sudo umount mnt_src
sudo umount mnt_dst
sudo mkdir mnt_src
sudo mkdir mnt_dst

sudo mount $ISOFILE mnt_src -o loop
sudo mount $TMPFILE mnt_dst  -o loop

sudo cp -fr mnt_src/* mnt_dst/
sudo mkdir -p  mnt_dst/home/admin
sudo mkdir -p mnt_dst/home/root
sudo mkdir -p mnt_dst/stats
echo 'LABEL="opendomodistro"
CONFDEVICE="1"
SYSDEVICE="1"
LOGDIR="stats"
' > /tmp/opendomo.cfg.test
sudo cp /tmp/opendomo.cfg.test mnt_dst/opendomo.cfg
sudo umount -l mnt_src
sudo umount -l mnt_dst
sudo rm -fr mnt_src mnt_dst
rm -fr $VDIFILE
vboxmanage convertdd $TMPFILE $VDIFILE --format VDI




